import request from "@/utils/request.js";

export const listTask = async () => {
    const res = await request.get('/task/list');
    return res.map(e => ({...e, value: e.id, label: e.name}))
}

export const operationTypeOptions = [
    {value: 1, label: '接单', type: 'primary'},
    {value: 2, label: '取消', type: 'info'},
    {value: 3, label: '开始执行', type: 'warning'},
    {value: 4, label: '更新进度', type: 'success'},
    {value: 5, label: '确认完成', type: 'primary'},
    {value: 6, label: '申请取消', type: 'info'},
]

export const fields = [
    {
        prop: 'taskId',
        label: '所属任务',
        type: 'remote-select',
        api: listTask,
        width: 120,
    },
    {
        prop: 'userId',
        label: '所属操作用户',
        type: 'number',
        width: 120,
    },
    {
        prop: 'operationType',
        label: '操作类型',
        type: 'tag',
        options: operationTypeOptions,
        search: true,
        width: 120,
    },
    {
        prop: 'remark',
        label: '操作备注',
        type: 'longtext',
        width: 'auto',
    },
    {
        prop: 'createTime',
        label: '操作时间',
        type: 'datetime',
        formHidden: true,
        width: 190,
    }
]